package com.inspur.edp.ai.flow;

import com.inspur.edp.ai.flow.api.FlowInvokeService;
import com.inspur.edp.ai.flow.api.ServiceContainer;
import com.inspur.edp.ai.flow.config.FlowConfig;
import com.inspur.edp.common.type.extension.ResourceConfig;
import com.inspur.edp.common.type.utils.JsonSerializeUtil;
import org.junit.jupiter.api.Test;

import javax.xml.ws.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lizhaorui
 * @date 2025/11/25
 * @description
 */
public class Selector {

    @Test
    public void test1() {
        String baseDir = this.getBaseDir();
        //设置元数据存储目录
        FlowConfig.FLOW_METADATA_DIR = baseDir + "flow-metadata";
        //设置类型定义目录
        ResourceConfig.TYPE_DSL_DIR = baseDir + "type-dsl";

        FlowInvokeService flowInvokeService = ServiceContainer.getService(FlowInvokeService.class);
        List<Object> parameters = new ArrayList<>();
        parameters.add("AAA");
        String flowId = "4100b4c1-e18a-40bd-ba98-69ce54216967";
        Map<String, Object> result = flowInvokeService.invoke(flowId, parameters);
        System.out.println(JsonSerializeUtil.toJson(result));
    }

    public String getBaseDir() {
        String userDir = System.getProperty("user.dir");
        return userDir.substring(0, userDir.length() - 12);
    }

}